package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.EquipmentType;
import com.dkd.manage.service.IEquipmentTypeService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 设备类型管理Controller
 * 
 * @author lengxx
 * @date 2025-03-24
 */
@RestController
@RequestMapping("/manage/equpmentType")
public class EquipmentTypeController extends BaseController
{
    @Autowired
    private IEquipmentTypeService equipmentTypeService;

    /**
     * 查询设备类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:equpmentType:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentType equipmentType)
    {
        startPage();
        List<EquipmentType> list = equipmentTypeService.selectequipmentTypeList(equipmentType);
        return getDataTable(list);
    }

    /**
     * 导出设备类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:equpmentType:export')")
    @Log(title = "设备类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentType equipmentType)
    {
        List<EquipmentType> list = equipmentTypeService.selectequipmentTypeList(equipmentType);
        ExcelUtil<EquipmentType> util = new ExcelUtil<EquipmentType>(EquipmentType.class);
        util.exportExcel(response, list, "设备类型管理数据");
    }

    /**
     * 获取设备类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:equpmentType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(equipmentTypeService.selectequipmentTypeById(id));
    }

    /**
     * 新增设备类型管理
     */
    @PreAuthorize("@ss.hasPermi('manage:equpmentType:add')")
    @Log(title = "设备类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentType equipmentType)
    {
        return toAjax(equipmentTypeService.insertequipmentType(equipmentType));
    }

    /**
     * 修改设备类型管理
     */
    @PreAuthorize("@ss.hasPermi('manage:equpmentType:edit')")
    @Log(title = "设备类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipmentType equipmentType)
    {
        return toAjax(equipmentTypeService.updateequipmentType(equipmentType));
    }

    /**
     * 删除设备类型管理
     */
    @PreAuthorize("@ss.hasPermi('manage:equpmentType:remove')")
    @Log(title = "设备类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equipmentTypeService.deleteequipmentTypeByIds(ids));
    }
}
